package wbw.action;

import com.google.protobuf.InvalidProtocolBufferException;

import msginfo.Msg.CMsg;
import msginfo.Msg.CMsgAI;
import msginfo.Msg.CMsgAIControl;
import wbw.server.ServerAgentThread;
import wbw.thread.DungeonMapThread;
//AI
public class AIAction extends Action {
	float[][] receive;
	public AIAction(ServerAgentThread sa, CMsg cmsg) throws InvalidProtocolBufferException{
		this.sa = sa;
		CMsgAI ai = CMsgAI.parseFrom(cmsg.getMsgbody());
		float[][] data = new float[ai.getAiControlCount()][];
		for(int i = 0; i < data.length; i++){
			CMsgAIControl control = ai.getAiControl(i);
			data[i] = new float[control.getAiCellCount()];
			for(int j = 0; j < data[i].length; j++){
				data[i][j] = control.getAiCell(j);
			}
		}
		receive = data;
	}
	
	@Override
	public Object doAction() {
		for(int i = 0; i < receive.length; i++){
			DungeonMapThread dmt = (DungeonMapThread)sa.currentScene;
			dmt.AILauncher.pushAction(receive[i]);
			System.out.println("push action");
		}
		return null;
	}
	
}
